package com.eistert.java.algorithm.tencommonalgorithms.prim;

/**
 * @Description: 普利姆算法
 * @Author: ai
 * @create: 2023-04-22 10:28
 */
public class PrimAlgorithm {

    public static void main(String[] args) {
        char[] data = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G'};
        int verxs = data.length;

        // 邻接矩阵的关系使用二维数组表示,10000 这个大数，表示两个点不联通
        int[][] weight = new int[][]{
                {10000, 5, 7, 10000, 10000, 10000, 2},
                {5, 10000, 10000, 9, 10000, 10000, 3},
                {7, 10000, 10000, 10000, 8, 10000, 10000},
                {10000, 9, 10000, 10000, 10000, 4, 10000},
                {10000, 10000, 8, 10000, 10000, 5, 4},
                {10000, 10000, 10000, 4, 5, 10000, 6},
                {2, 3, 10000, 10000, 4, 6, 10000}
        };

        // 创建 MGraph 对象
        MGraph graph = new MGraph(verxs);

        // 创建一个MinTree对象
        MinTree minTree = new MinTree();

        minTree.createGraph(graph, verxs, data, weight);
    }
}
